package com.mysite.angular.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mysite.angular.common.BaseController;
import com.mysite.angular.po.AcOrg;
import com.mysite.angular.service.OrgService;

@Controller
@RequestMapping("/sys/org")
public class OrgController extends BaseController {

	@Autowired
	private OrgService orgService;
	
	@RequestMapping(value = "/children", method = RequestMethod.POST)
	@ResponseBody
	public List<AcOrg> getChildren(@RequestBody Map<String, Object> searchMap, HttpServletRequest request) {
		List<AcOrg> resultList = orgService.getChildren(searchMap);
		return resultList;
	}
	
	@RequestMapping(value = "/delete", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> delete(@RequestBody AcOrg org, HttpServletRequest request) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("ret", orgService.delete(org) == 1);
		return resultMap;
	}
}
